package com.zbkj.front.controller.user;

import com.zbkj.common.annotation.LogControllerAnnotation;
import com.zbkj.common.enums.MethodType;
import com.zbkj.common.page.CommonPage;
import com.zbkj.common.request.*;
import com.zbkj.common.response.OrderTraceLogsRecordFrontPageDataResponse;
import com.zbkj.common.response.OrderTraceLogsRecordItemsDetailResponse;
import com.zbkj.common.response.OrderTraceLogsRecordItemsFrontPageDataResponse;
import com.zbkj.common.result.CommonResult;
import com.zbkj.service.service.OrderTraceLogsRecordItemsService;
import com.zbkj.service.service.OrderTraceLogsRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jdk.nashorn.internal.ir.annotations.Ignore;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 订单溯源号段表 前端控制器
 */
@Slf4j
@RestController
@RequestMapping("api/front/order/trace/logs/record")
@Api(tags = "用户端订单溯源号段") //配合swagger使用

public class UserOrderTraceLogsRecordController {

    @Autowired
    private OrderTraceLogsRecordService orderTraceLogsRecordService;

    @Autowired
    private OrderTraceLogsRecordItemsService orderTraceLogsRecordItemsService;

    /**
     * 分页显示订单溯源号段表
     *
     * @param orderNo          搜索条件
     * @param pageParamRequest 分页参数
     * @author Caiyc
     * @since 2025-08-04
     */
    @Ignore
    @ApiOperation(value = "溯源列表") //配合swagger使用
    @RequestMapping(value = "/{orderNo}/list", method = RequestMethod.GET)
    public CommonResult<CommonPage<OrderTraceLogsRecordFrontPageDataResponse>> getListByOrderNo(@PathVariable("orderNo") String orderNo,
                                                                   @ModelAttribute PageParamRequest pageParamRequest) {
        CommonPage<OrderTraceLogsRecordFrontPageDataResponse> orderTraceLogsRecordCommonPage =
                CommonPage.restPage(orderTraceLogsRecordService.getListByOrderNo(orderNo, pageParamRequest));
        return CommonResult.success(orderTraceLogsRecordCommonPage);
    }

    /**
     * 分页显示订单溯源号段明细表
     *
     * @param request          搜索条件
     * @param pageParamRequest 分页参数
     * @author Caiyc
     * @since 2025-08-04
     */
    //@PreAuthorize("hasAuthority('platform:activitystyle:list')")
    @ApiOperation(value = "日志列表") //配合swagger使用
    @RequestMapping(value = "/items/page/list", method = RequestMethod.GET)
    public CommonResult<CommonPage<OrderTraceLogsRecordItemsFrontPageDataResponse>> getList(@Validated OrderTraceLogsRecordItemsFrontSearchRequest request,
                                                                                       @ModelAttribute PageParamRequest pageParamRequest) {
        CommonPage<OrderTraceLogsRecordItemsFrontPageDataResponse> orderTraceLogsRecordItemsCommonPage =
                CommonPage.restPage(orderTraceLogsRecordItemsService.getListUserH5(request, pageParamRequest));
        return CommonResult.success(orderTraceLogsRecordItemsCommonPage);
    }

    /**
     * 查询订单溯源号段明细表详情
     * @param id Integer
     * @author Caiyc
     * @since 2025-08-04
     */
    @ApiOperation(value = "日志详情")
    @RequestMapping(value = "/items/info/{id}", method = RequestMethod.GET)
    public CommonResult<OrderTraceLogsRecordItemsDetailResponse> getDetails(@PathVariable("id") Integer id) {
        return CommonResult.success(orderTraceLogsRecordItemsService.getDetailsUserH5(id));
    }

}



